package com.linghui.videoplus.ipai.activity;

import com.linghui.videoplus.ipai.R;
import com.linghui.videoplus.ipai.VideoPlusApplication;
import com.linghui.videoplus.ipai.utils.Constants;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;

public class NetWorkErrorActivity extends BaseActivity implements OnClickListener {
	
	private int fromCode=REQUEST_CODE_DEFAULT;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_network_error);
		menuLayout = (com.linghui.videoplus.ipai.view.MenuLayout) this.findViewById(R.id.menuLayout);
		menuLayout.setOnClickListener(this);

		fromCode=getIntent().getIntExtra(FROM_CODE_KEY, REQUEST_CODE_DEFAULT);

	}

	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			VideoPlusApplication.exitApplication(this);
		}
		return super.onKeyDown(keyCode, event);
	}

	@Override
	public void onClick(View v) {
		int vId=v.getId();
		if(vId==R.id.photoLL||vId==R.id.photoImageView){
			VideoCascadeActivity.launch(this, REQUEST_CODE_NETWORK_ERROR,REQUEST_CODE_VIDEO_CASCADE);
		}else if(vId==R.id.cameraLL||vId==R.id.cameraImageView){
			CameraActivity.launch(this, REQUEST_CODE_NETWORK_ERROR,REQUEST_CODE_CAMERA);
		}else if(vId==R.id.homeLL||vId==R.id.homeImageView){
			BrowserActivity.launch(this, VideoPlusApplication.getUrlIndex(this),REQUEST_CODE_NETWORK_ERROR, REQUEST_CODE_DEFAULT);
		}
		
	}
	
	public static void launch(Activity mActivity, int fromCode, int toCode) {
		Intent intent = new Intent(mActivity, NetWorkErrorActivity.class);
		intent.putExtra(FROM_CODE_KEY, fromCode);
		intent.putExtra(TO_CODE_KEY, toCode);
		mActivity.startActivity(intent);
		mActivity.finish();
	}
	
}
